package com.caregiver.watch.business.file.controller;

import com.caregiver.watch.business.file.model.dto.UploadResponse;
import com.caregiver.watch.business.file.service.FileStorageServiceImpl;
import com.caregiver.watch.common.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name  = "UploadController", description = "文件上传服务")
@RestController
@RequestMapping("upload")
public class UploadController {
    
    @Autowired
    private FileStorageServiceImpl fileStorageServiceImpl;


    @Operation(summary = "上传图片", description = "上传图片")
    @PostMapping("/image")
    public R<UploadResponse> uploadImage(@RequestParam("file") MultipartFile file) {
        return R.ok(fileStorageServiceImpl.storeImage(file));
    }


    @Operation(summary = "上传音频", description = "上传音频")
    @PostMapping("/audio")
    public R<UploadResponse> uploadAudio(@RequestParam("file") MultipartFile file) {
        return R.ok(fileStorageServiceImpl.storeAudio(file));
    }
}